﻿using System;
using System.IO;
using System.Web.Http;
using Swashbuckle.Application;

namespace Yks.Notify.Client
{
    public static class SwaggerConfig
    {
        public static void Reqgister(HttpConfiguration config)
        {
            // 帮助文档  访问http://{apiRoot}/swagger
            config.EnableSwagger(c =>
            {
                c.SingleApiVersion("v1", "TCP.API");
                c.RootUrl(r => Configs.AppRootUrl.Replace("http://*", $"http://{r.RequestUri.DnsSafeHost}"));
                var xmls = Directory.GetFiles($"{AppDomain.CurrentDomain.BaseDirectory}", "*.xml",
                    SearchOption.AllDirectories);
                foreach (var xml in xmls)
                {
                    c.IncludeXmlComments(xml);
                }
            }).EnableSwaggerUi();
        }
    }
}